//
// Created by wxd on 2025/9/16.
// 点光源
//

#ifndef POINTLIGHT_H
#define POINTLIGHT_H

#include "Light.h"
#include "glm/glm.hpp"
#include <string>
#include "../glFramework/demo/obj/Object.h"

// 点光源的衰减系数, 分别控制常数项，一次项，二次项系数
struct AttenuationCoef {
    float c;
    float k1;
    float k2;

    AttenuationCoef(float c, float k1, float k2) : c(c), k1(k1), k2(k2) {}
};

class PointLight : public Light, public Object {
public:
    static std::string uPointLightColor;
    static std::string uPointLightIntensity;
    static std::string uPointLightPos;
    static std::string uPointLightAttenuation;

    PointLight() {
        mLightType = LightType::Point;
    }

    PointLight(glm::vec3 pos, glm::vec3 attenuation, glm::vec3 col, glm::vec3 intensity) : Light(LightType::Point, col, intensity, ""){
        mPosition = pos;
        mAttenuationCoef = { attenuation.x, attenuation.y, attenuation.z };
        mColor = col;
        mIntensity = intensity;
        mName = "PointLight";
    }

    LightType getType() const override { return LightType::Point; }

    std::unique_ptr<ILight> clone() const override {
        return std::make_unique<PointLight>(*this);
    }

    void setAttenuationCoefC(float c) { mAttenuationCoef.c = c; }
    void setAttenuationCoefK1(float k1) { mAttenuationCoef.k1 = k1; }
    void setAttenuationCoefK2(float k2) { mAttenuationCoef.k2 = k2; }

    void setAttenuationCoef(float c, float k1, float k2) {
        mAttenuationCoef.c = c;
        mAttenuationCoef.k1 = k1;
        mAttenuationCoef.k2 = k2;
    }

    glm::vec3 getAttenuationCoef() const {
        return glm::vec3(mAttenuationCoef.c, mAttenuationCoef.k1, mAttenuationCoef.k2);
    }

    float getAttenuationCoefC() const {
        return mAttenuationCoef.c;
    }

    float getAttenuationCoefK1() const {
        return mAttenuationCoef.k1;
    }

    float getAttenuationCoefK2() const {
        return mAttenuationCoef.k2;
    }

private:
    AttenuationCoef mAttenuationCoef { 0.f, 0.f, 0.f }; // 点光源的衰减系数
};



#endif //POINTLIGHT_H
